import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../../@core/services/auth.service';
import { User } from '../../models/user';
import is from '../../../../utils/is';
import { Router } from '@angular/router';
@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss'],
})
export class LoginComponent implements OnInit {
  constructor(private router: Router, private authService: AuthService) {}
  ngOnInit() {}
  async onLogin(): Promise<void> {
    const user = (await this.authService.login('admin', 'admin')) as User;
    if (!is.isEmpty(user)) {
      this.authService.setSession(user);
      this.router.navigate(['/']);
    }
  }
}
